package com.yungu.swift.order.utils;

import com.yungu.swift.assets.driver.model.dto.DriverDto;
import com.yungu.swift.order.model.dto.OrderDetailDto;
import com.yungu.swift.utils.DateUtils;
import com.yungu.swift.utils.StringUtils;

/**
 * 订单相关信息推送内容
 */
public class MessageContentUtils {

    /**
     * 跨城派单时发送司机短信
     */
    public static String joinAssignDriverMsg(OrderDetailDto orderDetailDto,Boolean isParcelOrder){
        StringBuilder content = new StringBuilder();
        if(isParcelOrder){
            content.append("收到跨城小件派单：寄件人手机：" + orderDetailDto.getSenderMobile()  + "；路线：" + orderDetailDto.getOriginAddress())
                    .append( "-" + orderDetailDto.getDestAddress() +"，出发时间：" + DateUtils.format(orderDetailDto.getDeparTime()) + "，货件信息：")
                    .append(orderDetailDto.getParcelInfoName() + "，备注：" + (StringUtils.isNotEmpty(orderDetailDto.getRemark()) ?
                            orderDetailDto.getRemark() : "无") + "，请准时取件！");
        }else{
            content.append("您已接单：乘客手机：" + orderDetailDto.getActualPasMob()  + "，路线：" + orderDetailDto.getOriginAddress())
                    .append("-" + orderDetailDto.getDestAddress() +"，出发时间：" + DateUtils.format(orderDetailDto.getDeparTime()) + "，用车人数：")
                    .append(orderDetailDto.getActualPasNum() + "；留言：" + (StringUtils.isNotEmpty(orderDetailDto.getRemark()) ?
                    orderDetailDto.getRemark() : "无") + "，请准时接驾！");
        }
        return content.toString();
    }

    /**
     * 跨城派单时发送乘客短信
     */
    public static String joinAssignPassengerMsg(String mobile, String carNum,Boolean isParcelOrder){
        StringBuilder content = new StringBuilder();
        if(isParcelOrder){
            content.append("派单成功！您的跨城小件订单已经安排好了，司机手机：")
                    .append(mobile)
                    .append("，车牌号：" + carNum + "，请提前准备好货件等待司机取件！");
        }else{
            content.append("派单成功！您的跨城拼车订单已经安排好了，司机手机：")
                    .append(mobile)
                    .append("，车牌号：" + carNum + "，请及时做好出发准备！");
        }
        return content.toString();
    }

    /**
     * 跨城改派时推送乘客消息
     */
    public static String joinChangeAssignPassengerPushMsg(OrderDetailDto orderDetailDto,Boolean isParcelOrder){
        String content;
        if(isParcelOrder){
            content = String.format("您有一笔跨城小件订单【取件时间：%s 寄件人手机号：%s】，因为特殊原因被改派给了新的司机，请及时注意调整行程，造成不便敬请谅解！",
                    DateUtils.format(orderDetailDto.getDeparTime()), orderDetailDto.getSenderMobile());
        }else{
            content = String.format("您有一笔跨城拼车订单【出发时间：%s 乘客手机号：%s】，因为特殊原因被改派给了新的司机，请及时注意调整行程，造成不便敬请谅解！",
                    DateUtils.format(orderDetailDto.getDeparTime()), orderDetailDto.getActualPasMob());
        }
        return content;
    }

    /**
     * 跨城改派时推送原司机消息
     */
    public static String joinChangeAssignOldDriverPushMsg(OrderDetailDto orderDetailDto,Boolean isParcelOrder){
        String content;
        if(isParcelOrder){
            content = String.format("您有一笔跨城小件订单【取件时间：%s 寄件人手机号：%s】，因为特殊原因被改派给了新的司机，请及时注意调整行程，造成不便敬请谅解！",
                    DateUtils.format(orderDetailDto.getDeparTime()), orderDetailDto.getSenderMobile());
        }else{
            content = String.format("您有一笔跨城拼车订单【出发时间：%s 乘客手机号：%s】，因为特殊原因被改派给了新的司机，请及时注意调整行程，造成不便敬请谅解！",
                    DateUtils.format(orderDetailDto.getDeparTime()), orderDetailDto.getActualPasMob());
        }
        return content;
    }

    /**
     * 跨城改派时推送新司机消息
     */
    public static String joinChangeAssignNewDriverPushMsg(OrderDetailDto orderDetailDto,Boolean isParcelOrder){
        StringBuilder content = new StringBuilder();
        if(isParcelOrder){
            content.append("收到跨城小件改派订单：寄件人手机：" + orderDetailDto.getSenderMobile() + "；路线：")
                    .append(orderDetailDto.getOriginAddress() + "-" + orderDetailDto.getDestAddress() + "；取件时间：")
                    .append(DateUtils.format(orderDetailDto.getDeparTime()) + "；货件信息：" + orderDetailDto.getParcelInfoName())
                    .append("；留言：" + (StringUtils.isNotEmpty(orderDetailDto.getRemark()) ? orderDetailDto.getRemark() : "无") + "，请准时取件！");
        }else{
            content.append("收到拼车改派订单：乘客手机：" + orderDetailDto.getActualPasMob() + "；路线：")
                    .append(orderDetailDto.getOriginAddress() + "-" + orderDetailDto.getDestAddress() + "；出发时间：")
                    .append(DateUtils.format(orderDetailDto.getDeparTime()) + "；用车人数：" + orderDetailDto.getActualPasNum())
                    .append("；留言：" + (StringUtils.isNotEmpty(orderDetailDto.getRemark()) ? orderDetailDto.getRemark() : "无") + "，请准时接驾！");
        }
        return content.toString();
    }


}
